import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class FoodPanelInOrder extends FlowPanel {
    Dimension lblSize = new Dimension(300, 60);
    Dimension spnSize = new Dimension(90, 60);
    Font font = new Font("Monospaced", Font.PLAIN, 24);
    private ArrayList<JComponent> components = new ArrayList<>();

    private JLabel lbl1 = new JLabel(FoodMenu.food[0] + " " + FoodMenu.price[0]);
    private JSpinner spn1 = new JSpinner();
    private JLabel lbl2 = new JLabel(FoodMenu.food[1] + " " + FoodMenu.price[1]);
    private JSpinner spn2 = new JSpinner();
    private JLabel lbl3 = new JLabel(FoodMenu.food[2] + " " + FoodMenu.price[2]);
    private JSpinner spn3 = new JSpinner();

    {
        components.add(lbl1);
        components.add(spn1);
        components.add(lbl2);
        components.add(spn2);
        components.add(lbl3);
        components.add(spn3);
        for (JComponent component: components
        ) {
            component.setFont(font);
            if (components.indexOf(component)%2==0){
                component.setPreferredSize(lblSize);
            } else {
                component.setPreferredSize(spnSize);
            }
            add(component);
        }
        addButton();
    }
    public FoodPanelInOrder(FlowLayout flowLayout){
        super(flowLayout);
    }

    public ArrayList<JComponent> getMyComponent() {
        return components;
    }

    public void clean(){
        spn1.setValue(new Integer(0));
        spn2.setValue(new Integer(0));
        spn3.setValue(new Integer(0));
    }
}
